package com.atgion.manager.controller;

import com.atgion.manager.service.SysResourceService;

import com.atgion.manager.util.RouteUtil;
import com.atgion.spzx.model.entity.system.ResourceParam;
import com.atgion.spzx.model.entity.system.SysResource;
import com.atgion.spzx.model.vo.base.Result;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@Slf4j
@RestController
@RequiredArgsConstructor
@Tag(name = "资源信息控制层", description = "资源信息控制层")
@RequestMapping("/sys/resource")
public class SysResourceController {

    private static final RouteUtil routeUtil = new RouteUtil();

    private final SysResourceService sysResourceService;

    @Operation(summary = "新增资源信息")
    @PostMapping(value = "/add")
    public Result<Integer> add(@RequestBody ResourceParam resourceParam) {
        SysResource sysResource = routeUtil.paramConvertSysResource(resourceParam);
        return sysResourceService.add(sysResource);
    }

    @Operation(summary = "删除资源信息")
    @DeleteMapping(value = "/removeById/{id}")
    public Result<String> removeById(@PathVariable("id") Long id) {
        sysResourceService.removeById(id);
        return Result.success();
    }

    @Operation(summary = "批量删除资源信息")
    @PostMapping(value = "/removeList")
    public Result<String> removeById(@RequestBody List<Integer> ids) {
        sysResourceService.removeByid(ids);
        return Result.success();
    }

}
